package ktt;

import static org.junit.Assert.assertTrue;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IRobotSnapshot;
import robocode.control.testing.RobotTestBed;

/**
 * Tests that Bubonic moves to the top of the map and the bottom of the map.
 * 
 * @author Kurt Teichman
 */
public class TestBubonicVerticalMovement extends RobotTestBed {
  /** True if the robot visited the top during the text case. */
  boolean visitedTop = false;
  /** True if the robot visited the bottom during the test case. */
  boolean visitedBottom = false;

  
  /**
   * Specifies that SittingDuck and Bubonic are to be matched up in this test case.
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.Walls,ktt.Bubonic";
  }
  
  /**
   * This test runs for 1 round.
   * @return The number of rounds. 
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * After each turn, check to see if we're at a corner.  If so, set the corresponding flag.
   * @param event Info about the current state of the battle.
   */
  @Override 
  public void onTurnEnded(TurnEndedEvent event) {
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
    double yPos = robot.getY();
    //System.out.println(robot.getBodyHeading());
    //Checks to see if the robot visited the top and bottom
    if (yPos > (height - 40)) {
      visitedTop = true;
    }
    
    if (yPos < 40) {
      visitedBottom = true;
    }
  }
  
  
  /**
   * After the battle, check to see that we've visited the corners. 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    assertTrue("Check Bottom and Top", visitedTop && visitedBottom);
  }

}
